//
//  CKLoginViewController.m
//  ckjntiku
//
//  Created by Eileen Vivian on 2017/11/22.
//  Copyright © 2017年 Eileen Vivian. All rights reserved.
//

#import "CKLoginViewController.h"
#import "CKTabbarViewController.h"
#import <AFNetworking.h>
#import <MBProgressHUD.h>
#import <SVProgressHUD.h>
#import "ZYForgotViewController.h"
#import "ZYRegisterViewController.h"
#import "NHRequestManager.h"
@interface CKLoginViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@property (weak, nonatomic) IBOutlet UITextField *accoutTF;
@property (weak, nonatomic) IBOutlet UITextField *codeTF;
@property (weak, nonatomic) IBOutlet UIButton *rigisterBtn;
@property (weak, nonatomic) IBOutlet UIView *firstView;
@property (weak, nonatomic) IBOutlet UIView *secondView;

@end

@implementation CKLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置圆角
    [_loginBtn.layer setCornerRadius:20];
    _loginBtn.layer.masksToBounds = YES;
    [_firstView.layer setCornerRadius:20];
    _firstView.layer.masksToBounds = YES;
    [_secondView.layer setCornerRadius:20];
    _secondView.layer.masksToBounds = YES;
    [_accoutTF addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];
    [_codeTF addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];
    // 判断下登录按钮能否点击
    [self textChange];
}
-(void)textChange{
    if (_accoutTF.text.length && _codeTF.text.length) {
        _loginBtn.enabled = YES;
    }else{
        _loginBtn.enabled =NO;
         [UFViewUtil showShortToast:@"请输入用户名和密码"];
    }
}
- (IBAction)enterBtn:(UIButton *)sender {
    [NHRequestManager GET:@"http://www.baidu.com" parameters:nil responseSeializerType:NHResponseSeializerTypeJSON success:^(id responseObject) {
    } failure:^(NSError *error) {
        CKTabbarViewController * tabbarVC = [[CKTabbarViewController alloc]init];
        [self presentViewController:tabbarVC animated:YES completion:nil];
    }];
}
- (IBAction)registerBtn:(UIButton *)sender {
    ZYRegisterViewController * registVC = [[ZYRegisterViewController alloc]init];
    [self presentViewController:registVC animated:YES completion:nil];
}
- (IBAction)forgotClick:(UIButton *)sender {
    ZYForgotViewController * forgotVC = [[ZYForgotViewController alloc]init];
    [self presentViewController:forgotVC animated:YES completion:nil];
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
